function cancel(id) {
    if ($.paramToObj().status === "1" && confirm('确定取消咨询单吗？')){
        ajax({
            url: "/api/order/cancel?id="+id,
            type: "post",
            dataType: "json",
            headers: {},
            success: function (result) {
                toast(result.msg);
                reloadWebview();
            }
        });
    }
}

function OrderBean(object, title, status) {
    var statusList = ["全部咨询单", "待回复", "已完成", "已取消"];
    if (object instanceof Object) {
        this.id = object.id;
        this.title = object.policyTitle;
        this.status = statusList[object.status];
    } else {
        this.id = object;
        this.title = title;
        this.status = statusList[status];
    }
}
function onPageReady() {
    var page = initPage(".main-bg", ".main", ".order-list", {
        url: "/api/order/list",
        type: "post",
        dataType: "json",
        headers: {},
        data: {status: $.paramToObj().status},
        success: function (result) {
            for (var i in result.data) {
                var item = new OrderBean(result.data[i]);
                $(".order-list").render("#item", item);
                if ($.paramToObj().status !== "1"){
                    $(".cancel").hide();
                }
                page.setLastRecordId(item.id);
            }
        }
    }, "id");
}